<template>
  <div class="add-data" v-if="props.showDialog">
    <Dialog
      diaTop="18"
      :headerName="'编辑'"
      :showDialog="true"
      @close="close"
      @save="save"
      saveLetter="保存"
      diaWidth="30"
      footerTop="20"
      footerBtm="30"
    >
      <template #content>
        <div class="content-wrap">
          <el-form
            ref="formRef"
            :model="formData"
            :rules="rules"
            label-width="150px"
            label-position="rigth"
          >
            <!-- <el-row>
              <el-col :span="24">
                <el-form-item label="用户名称：" prop="enterpriseName">
                  <el-input clearable v-model="formData.enterpriseName" />
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col :span="24">
                <el-form-item label="登录账号：" prop="enterpriseName">
                  <el-input clearable v-model="formData.enterpriseName" />
                </el-form-item>
              </el-col>
            </el-row> -->
            <el-row>
              <el-col :span="24">
                <el-form-item label="角色：" prop="roleid">
                  <el-select
                    v-model="formData.roleid"
                    clearable
                    placeholder="请选择"
                  >
                    <el-option
                      v-for="item in roleList"
                      :key="item.value"
                      :label="item.label"
                      :value="item.value"
                    />
                  </el-select>
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col :span="24">
                <el-form-item label="状态：" prop="status">
                  <el-select
                    v-model="formData.status"
                    clearable
                    placeholder="请选择"
                  >
                    <el-option
                      v-for="item in userStatusList"
                      :key="item.value"
                      :label="item.label"
                      :value="item.value"
                    />
                  </el-select>
                </el-form-item>
              </el-col>
            </el-row>
            <!-- <el-row>
              <el-col :span="24">
                <el-form-item label="备注：" prop="enterpriseName">
                  <el-input clearable v-model="formData.enterpriseName" />
                </el-form-item>
              </el-col>
            </el-row> -->
          </el-form>
        </div>
      </template>
    </Dialog>
  </div>
</template>
<script setup>
import Dialog from "@/components/DialogCross";
import Upload from "@/components/Upload";
import http from "@http";
import ElMessage from "@/components/ElMessage.js";
let props = defineProps(["showDialog", "addOrEditFlag", "sendMsg"]);
watch(
  () => props.sendMsg,
  () => {
    formData.id = props.sendMsg.id;
    formData.roleid = String(props.sendMsg.roleid);
    formData.status = String(props.sendMsg.status);
    console.log(formData.id);
  },
  { deep: true }
);
let emit = defineEmits(["update:showDialog", "save"]);
let params = reactive({});
let formData = reactive({});
let userStatusList = ref([]);
let formRef = ref(null);
let roleList = ref([]);
let close = () => {
 
  emit("update:showDialog", false);
};
let save = () => {

  formRef.value.validate((valid) => {
    if (valid) {
      http({ url: "/admPCUser/setRole", data: formData }).then((res) => {
        if (res.code == 0) {
          emit("save");
        }
      });
    }
  });
};
let options = ref([{ label: "fds,", value: "2" }]);
let rules = {
  roleid: [
    {
      required: true,
      message: "角色不能为空",
      trigger: "blur",
    },
  ],
  status: [
    {
      required: true,
      message: "状态不能为空",
      trigger: "blur",
    },
  ],
};
http({ url: "/listitem/getmodule", data: { module: "B09" } }).then((res) => {
  if (res.code == 0) {
    roleList.value = res.data.map((item) => {
      return {
        label: item.name,
        value: item.id,
      };
    });
  }
});
http({ url: "/listitem/getmodule", data: { module: "B10" } }).then((res) => {
  if (res.code == 0) {
    userStatusList.value = res.data.map((item) => {
      return {
        label: item.name,
        value: item.id,
      };
    });
  }
});
</script>
<style lang="scss" scoped>
/* 编辑企业详情页面 */
.add-data {
  .content-wrap {
    padding-right: 10px;
    padding-bottom: 20px;
    padding-top: 20px;
    .facility-code {
      img {
        width: 182px;
        height: 226px;
      }
    }
    .img-wrap {
      width: 344px;
      height: 103px;
      background: #f7f7f7;
      border-radius: 5px;
      border: 1px solid #bfbfbf;
      display: flex;
      justify-content: center;
      align-items: center;
      .content {
        button {
          margin-top: 5px;
          font-family: Source Han Sans CN;
          font-weight: 500;
          font-size: 20px;
          color: #0874fa;
        }
      }
    }
  }

  :deep(.el-form-item__label) {
    font-family: Source Han Sans CN;
    font-weight: 500 !important;
    font-size: 20px !important;
    color: #000 !important;
  }
  :deep(.el-input) {
    width: 100%;

    font-family: Source Han Sans CN;
    font-weight: 400;
    font-size: 18px;
    color: #666666 !important;
  }
  :deep(.el-select) {
    width: 100% !important;

    font-family: Source Han Sans CN;
    font-weight: 400;
    font-size: 18px;
    color: #666666 !important;
  }
  :deep(.el-input__inner) {
    font-family: Source Han Sans CN;
    font-weight: 400;
    font-size: 18px;
    color: #333;
  }
  :deep(.el-input) {
    width: 100% !important;
  }
  :deep(.el-input__wrapper, .el-textarea__inner) {
    box-shadow: none;
    font-family: Source Han Sans CN;
    font-weight: 400 !important;
    font-size: 18px !important;
    color: #666666 !important;
    background: #fff !important;
    border-radius: 5px !important;
    border: 1px solid #bfbfbf !important;

    height: 44px !important;
  }
  :deep(.el-input__inner::placeholder) {
    font-family: Source Han Sans CN;
    font-weight: 400;
    font-size: 18px;
    color: #999999;
  }
}
</style>
